<template>
<div>

<el-card class="box-card mb10">
	<div slot="header" class="clearfix ">
		<span>申报信息</span>
		<el-button style="float: right;" type="primary" size="mini"
		@click="shenpi"
		>审批</el-button>
	</div>
	<div >
		<div>申报事件：{{orderInfo.title}}</div>
		<div>申报人：{{orderInfo.name}}</div>
		<div>申报人身份证：{{orderInfo.cardno}}</div>
		<div>申报人电话：{{orderInfo.mobile}}</div>
		<div class="mb20">申报人时间：{{orderInfo.create_time}}</div>

		<el-card class="box-card mt10"
		v-for="(item, index) in documentInfo" :key="index"
		>
			<div slot="header" class="clearfix ">
				<span>{{item.name}}</span>
			</div>
			<div >
				<img width="200"  class="mr10" 
				v-for="(url, i) in imgFilter(orderInfo.paraObj[item.value])" :key="i"
				:src="$util.changeImg(url, 'w200')">
			</div>
		</el-card>

	</div>
</el-card>

<el-dialog title="审批" :visible.sync="shenpiDialogVisible">
  	<el-form ref="device"
		label-width="180px"	
		>
		<el-form-item label="审批不通过的理由:" >
			<el-input v-model="reason"></el-input>
		</el-form-item>
	</el-form>

  <div slot="footer" class="dialog-footer">
    <el-button @click="butongguo">审批不通过</el-button>
    <el-button type="primary" @click="tongguo">审批通过</el-button>
  </div>
</el-dialog>

</div>
</template>

<script>

import { mapGetters } from 'vuex'

export default {
	
	name : 'eventinfo',
	
	data () {
		return {
		  	documentInfo : [],
		  	orderInfo : {},

		  	shenpiDialogVisible : false,

		  	reason : '',
		}
	},

	props : {

	},

	components : {
		
	},

	computed : {
		...mapGetters([
			
		]),
	},

	methods : {
		init () {
			this.$http({
				fun : 'documentInfo',
				item_id : this.$route.query.id,
				cb : res => {
					console.log('documentInfo');
					console.log(res);

					this.$http({
						fun : 'orderInfo',
						code : this.$route.query.code,
						cb : res1 => {
							console.log('orderinfo');
							console.log(res1);
							console.log(JSON.parse(res1.params));
							res1['paraObj'] = JSON.parse(res1.params);
							this.documentInfo = res;
							this.orderInfo = res1;
						}
					});

				}
			});
		},

		imgFilter  (value) {

			if(value == undefined || value == '') return [];

			const arr = value.split(',');

			return arr;
		},

		shenpi () {
			this.shenpiDialogVisible = true;
		},

		tongguo () {
			this.$http({
				fun : 'orderUpdate',
				code : this.orderInfo.code,
				reason : '',
				state : '1',
				cb : res => {
					console.log(res);
				}
			});
		},

		butongguo () {

			this.$http({
				fun : 'orderUpdate',
				code : this.orderInfo.code,
				state : '3',
				reason : this.reason,
				cb : res => {
					console.log(res);
				}
			});
		},
	},

	watch : {
	    
	},

	mounted () {
		this.init();
	},

}
</script>

<style scoped>

</style>
